#include <gflags/gflags.h>
#include "../../../common/data_es.hpp" 


DEFINE_bool(run_mode,false,"程序的运行模式，false： 调试 true： 发布");
DEFINE_string(log_file,"","发布模式下，向文件中输出，如果是调试模式下，模式是stdout");
DEFINE_int32(log_level,0,"发布模式下，用于指定的日志输出等级");

DEFINE_string(es_host, "http://127.0.0.1:9200/", "es服务器URL");

int main(int argc,char* argv[])
{
    google::ParseCommandLineFlags(&argc,&argv,true);
    init_logger(FLAGS_run_mode,FLAGS_log_file,FLAGS_log_level);

    auto es_client = ESClientFactory::create({FLAGS_es_host});
    auto es_user = std::make_shared<ESUser>(es_client);
    es_user->createIndex();

    es_user->appendData("用户ID1","手机号1","昵称1","签名1","头像1");
    es_user->appendData("用户ID2","手机号2","昵称2","签名2","头像2");
    auto res = es_user->search("昵称",{"用户ID1"});
    for(auto& e : res) {
        std::cout << "-----------------" << std::endl;
        std::cout << e.user_id() << std::endl;
        std::cout << *e.phone() << std::endl;
        std::cout << *e.nickname() << std::endl;
        std::cout << *e.description() << std::endl;
        std::cout << *e.avatar_id() << std::endl;
    }


    return 0; 
}